<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var numberOfWeeks = function (milestones) {
      let sum = 0, max = 0
      for (let c of milestones) {
        sum += c
        max = Math.max(c, max)
      }
      if (max * 2 <= sum) return sum
      else return (sum - max) * 2 + 1
    };
    console.log(numberOfWeeks([1, 2, 3]));
  </script>
</body>

</html>